package com.optimize.jvm.memory;

/**
 * ClassName: StackTest
 * Description: Java栈
 * Date: 2017/3/13 16:11
 *
 * @author SAM SHO
 * @version V1.0
 */
public class StackTest {
    static int count = 0;
    public static void main(String[] args) {
        StackTest stack = new StackTest();
        stack.deepOfStack();
    }

    /**
     * 使用递归展示栈溢出
     * 默认深度为 45415
     * 修改栈：-Xss128k 后，深度为 1804
     */
    void deepOfStack() {
        try {
            test();
        }catch (Throwable e) {
            System.out.println("栈执行的深度: " + count);
        }

    }

    void test() {
        count++;
        test();
    }
}
